package cn.edu.scau.cmi.linjinyong.multiton;

import java.util.ArrayList;
import java.util.List;

public class Marshal {
	private static List<Marshal> marshals = new ArrayList<Marshal>(10);
	private String name;
	
	private Marshal(String name) {
		this.name = name;
	}
	
	public static Marshal createMarshal(String name) {
		Marshal marshal = null;
		if(marshals.size()<10) {
			marshal = new Marshal(name);
			marshals.add(marshal);
		}
		return marshal;
	}

	@Override
	public String toString() {
		String s = super.toString();
		return s.substring(s.indexOf("Marshal@"));
	}

	//getter & setter
	public String getName() {
		return name;
	}
	public void setName(String name) {
		this.name = name;
	}
	public static List<Marshal> getMarshals() {
		return marshals;
	}
}
